//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include "SMIData.h"

#include <string.h>
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#define LENGTHTEXT 1000
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
SMIData::SMIData () {
   
  this->ligand   = new String ();
  this->id       = new String ();
  this->toString = new String ();
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
SMIData::SMIData (const SMIData& smiData) {
  
  this->ligand   = new String (smiData.ligand);
  this->id       = new String (smiData.id);
  this->toString = new String ();
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
SMIData::SMIData (const SMIData* smiData) {
  
  this->ligand   = new String (smiData->ligand);
  this->id       = new String (smiData->id);
  this->toString = new String ();
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
SMIData::~SMIData () {
  
  if (this->ligand)   delete this->ligand;
  if (this->id)       delete this->id;
  if (this->toString) delete this->toString;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void SMIData::Ligand (String* ligand) {
  
  if (ligand) this->ligand->In(ligand);
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void SMIData::ID (String* id) {
  
  if (id) this->id->In(id);
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* SMIData::Ligand (void) {
  
  return this->ligand;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* SMIData::ID (void) {
  
  return this->id;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
bool SMIData::LoadData (String* data) {
  
  if (!data || !data->Length()) return false;
  
  return this->LoadData(data->Out());
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
bool SMIData::LoadData (char* data) {
  
  if (!data || !strlen(data)) return false;
  
  char ligandIn [LENGTHTEXT];
  char idIn [LENGTHTEXT];
  char rest [LENGTHTEXT]; 
  
  sscanf (data, "%s %s %s", ligandIn, idIn, rest);
  
  if (ligandIn) this->ligand->In(ligandIn);
  if (idIn)     this->id->In(idIn);
  
  return true;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* SMIData::ToString (void) {
  
  this->toString->In("");
  
  char data [LENGTHTEXT]; 
  
  sprintf (data, "%s %s\0", this->ligand->Out(), this->id->Out());
  
  this->toString->Add(data);
  
  return this->toString;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
SMIData SMIData::operator= (const SMIData& smiData) {
  
  this->ligand->In(smiData.ligand);
  this->id->In(smiData.id);
  
  return *this;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
